package com.springStudy.boot.redis.firstDemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.AbstractEnvironment;

@SpringBootApplication(scanBasePackages = "com.springStudy.boot.redis.firstDemo")
public class FirstDemoApp {
    private static ApplicationContext applicationContext;

    public static void main(String[] args) {
        System.setProperty("server.port", "9080");
//        System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "first");

        applicationContext = SpringApplication.run(FirstDemoApp.class);

        System.out.println("started");
        String[] beans = SpringContextHolder.getApplicationContext()
                .getBeanDefinitionNames();
        for (String beanName : beans) {
            Class<?> beanType = SpringContextHolder.getApplicationContext()
                    .getType(beanName);
            System.out.println("BeanName:" + beanName);
//            System.out.println("Bean的类型：" + beanType);
//            System.out.println("Bean所在的包：" + beanType.getPackage());
//            System.out.println("Bean：" + SpringContextHolder.getApplicationContext().getBean(
//                    beanName));
        }

    }
}
